import 'lib.dart';

void main(List<String> args) {
  Person person = Person('jack', 18);
  person.say();

  Person2 person2 = Person2('jim', 20);
  person2.say();

  Person3 person3 = Person3.create('ross', 21);
  person3.say();

  People people = new People('tom', 25);
  people.say();
  print(people.name);
}

class Person {
  String? name;
  int? age;

  Person(String name, int age) {
    this.name = name;
    this.age = age;
  }

  say() {
    print('$name今年$age');
  }
}

// 默认构造函数简写
class Person2 {
  String? name;
  int? age;

  Person2(this.name, this.age);

  say() {
    print('$name今年$age');
  }
}

// 命名构造函数
class Person3 {
  String? name;
  int? age;

  Person3(this.name, this.age);
  Person3.create(this.name, this.age);

  say() {
    print('$name今年$age');
  }
}
